<template>
  <div>
    <accountList></accountList>
    <div>
      <h3>请输入转账信息( 转账前请先去 账户管理-解锁账户取得私钥 )</h3>
        <el-input style="width: 800px" placeholder="请输入转出地址" v-model="transInfo.fromAddr">
          <template slot="prepend">转出地址：</template>
        </el-input><br>
        <el-input style="width: 800px" placeholder="请输入私钥" v-model="transInfo.privateKey">
          <template slot="prepend">私钥：</template>
        </el-input><br><br>
        <el-input style="width: 800px" placeholder="请输入转入地址" v-model="transInfo.toAddr">
          <template slot="prepend">转入地址：</template>
        </el-input><br><br>
        <el-input style="width: 300px" placeholder="请输入转账金额" v-model="transInfo.money">
          <template slot="prepend">金额：</template>
        </el-input>
        <el-input style="width: 300px" placeholder="请输入gasLimit" v-model="transInfo.gasLimit">
          <template slot="prepend">gasLimit：</template>
        </el-input>
        <el-input style="width: 300px" placeholder="请输入转账备注信息" v-model="transInfo.data">
          <template slot="prepend">备注：</template>
        </el-input>
      <br><br>
        <el-button type="primary" @click="sendTransaction">提交转账</el-button>
      <div>
        <el-descriptions column=1 title="转账结果">
          <el-descriptions-item label="交易hash">{{transHash.transHash}}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  <router-view></router-view>
  </div>
</template>

<script>
import accountList from "../components/accountList";
export default {
  name: "page2",
  components: {accountList},

  data() {
    return {
      transInfo: {
        fromAddr: '',
        privateKey: '',
        toAddr: '',
        money: '',
        gasLimit: '',
        data: '',
      },
      transHash: '',
    }
  },

  methods: {
    sendTransaction() {
      this.axios.post("/sendTransaction", {
        fromAddr: this.transInfo.fromAddr,
        privateKey: this.transInfo.privateKey,
        toAddr: this.transInfo.toAddr,
        money: this.transInfo.money,
        gasLimit: this.transInfo.gasLimit,
        data: this.transInfo.data,
      }).then(res => {
        this.transHash = res.data;
      })
    },
  },

}
</script>

<style scoped>

</style>
